home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 52 / Amiga Format AFCD52 (Issue 136, May 2000).iso / -in_the_mag- / javascript / part5 / scripts / tip.js < prev    next >
Text File  |  2000-02-07  |  3KB  |  85 lines

  1.  
  2. <SCRIPT LANGUAGE= "JavaScript1.1">
  3. <!--Cast invisibility spell here
  4. //The Tip Machine is a tip display script that is very
  5. //resistant to problems.  Mostly because it is very
  6. //simple. This "low tech" javaScript solution was
  7. //written by Mark Naker (TIMELORDS ANONYMOUS) for
  8. //NERO Colorado. It can be used freely as long as
  9. //this comment block remains.
  10. // Tip Machine version 1.0
  11. //Copyright TIMELORDS ANONYMOUS 1997
  12. function chngNext(){
  13.  document.tipMachine.shownext.value = "Y"
  14.  tipMach();
  15. }
  16. function chngPrev(){
  17.  document.tipMachine.showprev.value = "Y"
  18.  tipMach();
  19. }
  20. function tipMach(){
  21. var totalTips = 4;     //set total number of tips here
  22. if ((document.tipMachine.shownext.value == "Y") &&
  23. (document.tipMachine.showprev.value == "N")){
  24. var tipShow = (parseInt(document.tipMachine.nowShowing.value) +1);
  25.  if (tipShow > totalTips){
  26.   var tipShow = 1;}
  27.  }
  28. if ((document.tipMachine.showprev.value == "Y") &&
  29. (document.tipMachine.shownext.value == "N")){
  30. var tipShow = (parseInt(document.tipMachine.nowShowing.value) - 1);
  31.  if (tipShow < 1){
  32.   var tipShow = totalTips;}
  33.  }
  34. if ((document.tipMachine.showprev.value == "N") &&
  35. (document.tipMachine.shownext.value == "N")){
  36.  var tipShow = (Math.random() * totalTips);
  37.  var tipShow = Math.ceil(tipShow);}
  38. //additional tips can be added here just follow the pattern
  39. //remember to use single quotes in the tip text or else bad
  40. //things will happen. Do it this way "text 'more text' text"
  41. if (tipShow == 1) {
  42. var _tip =  "Paste this code into your page and jazz up the formatting however you want.  Then put in your tips";
  43. }
  44. if (tipShow == 2) {
  45. var _tip =  "The script can handle a virtually unlimited number of tips.";
  46. }
  47. if (tipShow == 3) {
  48. var _tip =  "The best part about this script is it doesnt reload the page.";
  49. }
  50. if (tipShow == 4) {
  51. var _tip =  "Sometimes the low tech 'it doesnt break' solution is the best.";
  52. }
  53. if (tipShow == 5) {
  54. var _tip =  "Contact me if you want to know when I update this script or for information about other scripts Ive written.";
  55. }
  56. if (tipShow == 6) {
  57. var _tip =  "HTML Goodies page is a good source for scripts when you dont feel like writing them yourself, or dont know how to write them.";
  58. }
  59. if (tipShow == 7) {
  60. var _tip =  "You dont have to put tips here you could put any text you want to display like this in here.";
  61. }
  62. if (tipShow == 5) {
  63. var _tip =  "The most important thing to remember is DONT PANIC.";
  64. }
  65. document.tipMachine.tipsHere.value = _tip;
  66. document.tipMachine.nowShowing.value = tipShow;
  67. document.tipMachine.ofTotal.value = totalTips;
  68. document.tipMachine.shownext.value = "N";
  69. document.tipMachine.showprev.value = "N";
  70. }
  71. //Dispell invisibility here-->
  72. </SCRIPT>
  73. </head>
  74. <body bgcolor="#FFFFFF">
  75. <center><h2><i>Tip Machine</i></h2>
  76. <FORM NAME="tipMachine" METHOD="post">
  77. <TEXTAREA NAME="tipsHere" ROWS=8 COLS=60 WRAP="virtual" onFocus="this.blur();">Tip Machine javaScript by Mark
  78. Naker.</TEXTAREA><br>
  79. <INPUT TYPE="button" VALUE="RANDOM" onClick="tipMach();">
  80. <INPUT TYPE="button" VALUE="NEXT" onClick="chngNext();"><INPUT TYPE="button" VALUE="PREV" onClick="chngPrev();">
  81. </center><br>
  82. Now showing tip number: <INPUT TYPE="text" SIZE=3 NAME="nowShowing" value="1" onFocus="this.blur();">
  83.  of <INPUT TYPE="text" SIZE=3 NAME="ofTotal" onFocus="this.blur();"><br><input type="hidden" name="shownext" value="N"><input type="hidden" name="showprev" value="N">
  84. </FORM>
  85. </center>